{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "293c8bf1-a728-41f6-9605-6cc0329cece1",
   "metadata": {},
   "source": [
    "# 数据处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c4573247-33f9-4b46-90d9-1dce50f35185",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "db80a15a-d833-4f8a-837f-57a79081c1f1",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "df = pd.read_csv(r\"./out/data.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "c0215f03-cedd-47e5-9781-97f049dbca65",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "de10ecef-d1a1-476f-ba1b-0e4f40a9eac9",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Key Developments By Date</th>\n",
       "      <th>Key Developments by Type</th>\n",
       "      <th>Company Name(s)</th>\n",
       "      <th>Key Development Headline</th>\n",
       "      <th>Key Development Situation</th>\n",
       "      <th>Key Development Sources</th>\n",
       "      <th>Geographic Locations</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2022-07-26</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Wallbridge Mining Company Limited (TSX:WM)</td>\n",
       "      <td>Wallbridge Mining Company Limited Reports Sign...</td>\n",
       "      <td>Wallbridge Mining Company Limited reported pos...</td>\n",
       "      <td>GlobeNewswire – Canada</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2021-04-12</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>International Business Machines Corporation (N...</td>\n",
       "      <td>IBM Announces Kyndryl, New Independent Company</td>\n",
       "      <td>IBM announced that Kyndryl will be the name of...</td>\n",
       "      <td>Canada News Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2021-10-18</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Lazydays Holdings, Inc. (NasdaqCM:GORV)</td>\n",
       "      <td>Lazydays RV Announces Plans to Open Omaha Deal...</td>\n",
       "      <td>Lazydays, The RV Authority, announced that it ...</td>\n",
       "      <td>PR Newswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2023-05-09</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Good Times Restaurants Inc. (NasdaqCM:GTIM)</td>\n",
       "      <td>Good Times Restaurants Inc. Plans to Open New ...</td>\n",
       "      <td>Good Times Restaurants Inc. announced that it ...</td>\n",
       "      <td>Transcript Collection</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2021-12-22</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Generation Mining Limited (TSX:GENM)</td>\n",
       "      <td>Generation Mining Limited Agrees to Enter into...</td>\n",
       "      <td>Generation Mining Limited announced that it ha...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2022-12-02</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Natural Grocers by Vitamin Cottage, Inc. (NYSE...</td>\n",
       "      <td>Natural Grocers Hiring Select Positions for Ne...</td>\n",
       "      <td>Natural Grocers is currently seeking additiona...</td>\n",
       "      <td>PR Newswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2022-12-12</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Southern Empire Resources Corp. (TSXV:SMP)</td>\n",
       "      <td>Southern Empire Resources Corp. Expands Its Mi...</td>\n",
       "      <td>Southern Empire Resources Corp. announces that...</td>\n",
       "      <td>Other</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2022-08-15</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Nate's Food Co. (OTCPK:NHMD)</td>\n",
       "      <td>Nate’s Food Co. Expands Bitcoin Mining Operati...</td>\n",
       "      <td>Nate’s Food Co. announced that it has purchase...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2023-06-15</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Rayonier Advanced Materials Inc. (NYSE:RYAM)</td>\n",
       "      <td>Rayonier Advanced Materials Inc. Announces the...</td>\n",
       "      <td>Rayonier Advanced Materials Inc. hosted a cere...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2022-05-10</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Emerald Holding, Inc. (NYSE:EEX)</td>\n",
       "      <td>Emerald Holding, Inc. Announces New Division D...</td>\n",
       "      <td>Emerald Holding, Inc. announced the creation o...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2021-03-24</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Clean Seed Capital Group Ltd. (TSXV:CSX)</td>\n",
       "      <td>Clean Seed Capital Group Ltd. to Break Ground ...</td>\n",
       "      <td>Clean Seed Capital Group Ltd. announces the Co...</td>\n",
       "      <td>SEDAR</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2023-12-01</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Kermode Resources Ltd. (TSXV:KLM)</td>\n",
       "      <td>Kermode Resources Ltd. Receives Work Permit fo...</td>\n",
       "      <td>Kermode Resources Ltd. announced the receipt o...</td>\n",
       "      <td>SEDAR</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2021-07-29</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Rogers Communications Inc. (TSX:RCI.B)</td>\n",
       "      <td>Rogers Communications Continues Canada’s 5G Ne...</td>\n",
       "      <td>Rogers Communications announced that it invest...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2022-08-10</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Toll Brothers, Inc. (NYSE:TOL)</td>\n",
       "      <td>Toll Brothers Announces Model Homes Now Open a...</td>\n",
       "      <td>Toll Brothers, Inc. announced the opening of 1...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2021-11-16</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>The Wendy's Company (NasdaqGS:WEN)</td>\n",
       "      <td>The Wendy's Company's Opens 1,000th Internatio...</td>\n",
       "      <td>The Wendy's Company announced the opening of i...</td>\n",
       "      <td>PR Newswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2021-04-07</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Curaleaf Holdings, Inc. (TSX:CURA)</td>\n",
       "      <td>Curaleaf Holdings, Inc. Establishes Curaleaf I...</td>\n",
       "      <td>Curaleaf Holdings, Inc. has simultaneously est...</td>\n",
       "      <td>Canada News Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2022-03-28</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Delta Apparel, Inc. (NYSEAM:DLA)</td>\n",
       "      <td>Delta Apparel, Inc. Launches New ‘On-Demand’ D...</td>\n",
       "      <td>Delta Apparel, Inc. announced the expansion of...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2021-05-21</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>KB Home (NYSE:KBH)</td>\n",
       "      <td>KB Home Announces the Grand Opening of Fishers...</td>\n",
       "      <td>KB Home announced the grand opening of Fishers...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2023-05-31</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>PureCycle Technologies, Inc. (NasdaqCM:PCT)</td>\n",
       "      <td>PureCycle Technologies, Inc. Finalizes Financi...</td>\n",
       "      <td>PureCycle Technologies, Inc. announced that it...</td>\n",
       "      <td>Other</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2023-07-17</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Verizon Communications Inc. (NYSE:VZ)</td>\n",
       "      <td>Verizon Continues to Upgrade Daytona's Best Ne...</td>\n",
       "      <td>Verizon has recently made major upgrades to th...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Key Developments By Date Key Developments by Type  \\\n",
       "0                2022-07-26      Business Expansions   \n",
       "1                2021-04-12      Business Expansions   \n",
       "2                2021-10-18      Business Expansions   \n",
       "3                2023-05-09      Business Expansions   \n",
       "4                2021-12-22      Business Expansions   \n",
       "5                2022-12-02      Business Expansions   \n",
       "6                2022-12-12      Business Expansions   \n",
       "7                2022-08-15      Business Expansions   \n",
       "8                2023-06-15      Business Expansions   \n",
       "9                2022-05-10      Business Expansions   \n",
       "10               2021-03-24      Business Expansions   \n",
       "11               2023-12-01      Business Expansions   \n",
       "12               2021-07-29      Business Expansions   \n",
       "13               2022-08-10      Business Expansions   \n",
       "14               2021-11-16      Business Expansions   \n",
       "15               2021-04-07      Business Expansions   \n",
       "16               2022-03-28      Business Expansions   \n",
       "17               2021-05-21      Business Expansions   \n",
       "18               2023-05-31      Business Expansions   \n",
       "19               2023-07-17      Business Expansions   \n",
       "\n",
       "                                      Company Name(s)  \\\n",
       "0          Wallbridge Mining Company Limited (TSX:WM)   \n",
       "1   International Business Machines Corporation (N...   \n",
       "2             Lazydays Holdings, Inc. (NasdaqCM:GORV)   \n",
       "3         Good Times Restaurants Inc. (NasdaqCM:GTIM)   \n",
       "4                Generation Mining Limited (TSX:GENM)   \n",
       "5   Natural Grocers by Vitamin Cottage, Inc. (NYSE...   \n",
       "6          Southern Empire Resources Corp. (TSXV:SMP)   \n",
       "7                        Nate's Food Co. (OTCPK:NHMD)   \n",
       "8        Rayonier Advanced Materials Inc. (NYSE:RYAM)   \n",
       "9                    Emerald Holding, Inc. (NYSE:EEX)   \n",
       "10           Clean Seed Capital Group Ltd. (TSXV:CSX)   \n",
       "11                  Kermode Resources Ltd. (TSXV:KLM)   \n",
       "12             Rogers Communications Inc. (TSX:RCI.B)   \n",
       "13                     Toll Brothers, Inc. (NYSE:TOL)   \n",
       "14                 The Wendy's Company (NasdaqGS:WEN)   \n",
       "15                 Curaleaf Holdings, Inc. (TSX:CURA)   \n",
       "16                   Delta Apparel, Inc. (NYSEAM:DLA)   \n",
       "17                                 KB Home (NYSE:KBH)   \n",
       "18        PureCycle Technologies, Inc. (NasdaqCM:PCT)   \n",
       "19              Verizon Communications Inc. (NYSE:VZ)   \n",
       "\n",
       "                             Key Development Headline  \\\n",
       "0   Wallbridge Mining Company Limited Reports Sign...   \n",
       "1      IBM Announces Kyndryl, New Independent Company   \n",
       "2   Lazydays RV Announces Plans to Open Omaha Deal...   \n",
       "3   Good Times Restaurants Inc. Plans to Open New ...   \n",
       "4   Generation Mining Limited Agrees to Enter into...   \n",
       "5   Natural Grocers Hiring Select Positions for Ne...   \n",
       "6   Southern Empire Resources Corp. Expands Its Mi...   \n",
       "7   Nate’s Food Co. Expands Bitcoin Mining Operati...   \n",
       "8   Rayonier Advanced Materials Inc. Announces the...   \n",
       "9   Emerald Holding, Inc. Announces New Division D...   \n",
       "10  Clean Seed Capital Group Ltd. to Break Ground ...   \n",
       "11  Kermode Resources Ltd. Receives Work Permit fo...   \n",
       "12  Rogers Communications Continues Canada’s 5G Ne...   \n",
       "13  Toll Brothers Announces Model Homes Now Open a...   \n",
       "14  The Wendy's Company's Opens 1,000th Internatio...   \n",
       "15  Curaleaf Holdings, Inc. Establishes Curaleaf I...   \n",
       "16  Delta Apparel, Inc. Launches New ‘On-Demand’ D...   \n",
       "17  KB Home Announces the Grand Opening of Fishers...   \n",
       "18  PureCycle Technologies, Inc. Finalizes Financi...   \n",
       "19  Verizon Continues to Upgrade Daytona's Best Ne...   \n",
       "\n",
       "                            Key Development Situation Key Development Sources  \\\n",
       "0   Wallbridge Mining Company Limited reported pos...  GlobeNewswire – Canada   \n",
       "1   IBM announced that Kyndryl will be the name of...        Canada News Wire   \n",
       "2   Lazydays, The RV Authority, announced that it ...             PR Newswire   \n",
       "3   Good Times Restaurants Inc. announced that it ...   Transcript Collection   \n",
       "4   Generation Mining Limited announced that it ha...           GlobeNewswire   \n",
       "5   Natural Grocers is currently seeking additiona...             PR Newswire   \n",
       "6   Southern Empire Resources Corp. announces that...                   Other   \n",
       "7   Nate’s Food Co. announced that it has purchase...           GlobeNewswire   \n",
       "8   Rayonier Advanced Materials Inc. hosted a cere...           Business Wire   \n",
       "9   Emerald Holding, Inc. announced the creation o...           Business Wire   \n",
       "10  Clean Seed Capital Group Ltd. announces the Co...                   SEDAR   \n",
       "11  Kermode Resources Ltd. announced the receipt o...                   SEDAR   \n",
       "12  Rogers Communications announced that it invest...           GlobeNewswire   \n",
       "13  Toll Brothers, Inc. announced the opening of 1...           GlobeNewswire   \n",
       "14  The Wendy's Company announced the opening of i...             PR Newswire   \n",
       "15  Curaleaf Holdings, Inc. has simultaneously est...        Canada News Wire   \n",
       "16  Delta Apparel, Inc. announced the expansion of...           Business Wire   \n",
       "17  KB Home announced the grand opening of Fishers...           Business Wire   \n",
       "18  PureCycle Technologies, Inc. announced that it...                   Other   \n",
       "19  Verizon has recently made major upgrades to th...           GlobeNewswire   \n",
       "\n",
       "                  Geographic Locations  \n",
       "0   United States and Canada (Primary)  \n",
       "1   United States and Canada (Primary)  \n",
       "2   United States and Canada (Primary)  \n",
       "3   United States and Canada (Primary)  \n",
       "4   United States and Canada (Primary)  \n",
       "5   United States and Canada (Primary)  \n",
       "6   United States and Canada (Primary)  \n",
       "7   United States and Canada (Primary)  \n",
       "8   United States and Canada (Primary)  \n",
       "9   United States and Canada (Primary)  \n",
       "10  United States and Canada (Primary)  \n",
       "11  United States and Canada (Primary)  \n",
       "12  United States and Canada (Primary)  \n",
       "13  United States and Canada (Primary)  \n",
       "14  United States and Canada (Primary)  \n",
       "15  United States and Canada (Primary)  \n",
       "16  United States and Canada (Primary)  \n",
       "17  United States and Canada (Primary)  \n",
       "18  United States and Canada (Primary)  \n",
       "19  United States and Canada (Primary)  "
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d7813a60-9f4b-4e9b-bcc3-1a142f2ae6d2",
   "metadata": {},
   "source": [
    "## 类型转换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "40de2b04-cd19-4cb6-bf96-339dff4ec0c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "df[\"Key Developments By Date\"] = pd.to_datetime(df['Key Developments By Date'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "87a067af-6f1e-4b86-ae72-1267a37a4692",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "df = df.convert_dtypes()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "36303ef7-a870-424f-9835-45ca82cc23f7",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Key Developments By Date     datetime64[ns]\n",
       "Key Developments by Type     string[python]\n",
       "Company Name(s)              string[python]\n",
       "Key Development Headline     string[python]\n",
       "Key Development Situation    string[python]\n",
       "Key Development Sources      string[python]\n",
       "Geographic Locations         string[python]\n",
       "dtype: object"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c780635b-2494-46b8-a0aa-d342b7a8a4c7",
   "metadata": {},
   "source": [
    "## 数据判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "d6a9cdbb-2547-4018-8f76-9cc9826aac14",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "df2 = df[df[\"Key Developments By Date\"] > pd.Timestamp('2022')]# 选择col列的值大于0.5的行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "81690f7c-a6a4-4a94-a19a-249302e5da89",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Key Developments By Date</th>\n",
       "      <th>Key Developments by Type</th>\n",
       "      <th>Company Name(s)</th>\n",
       "      <th>Key Development Headline</th>\n",
       "      <th>Key Development Situation</th>\n",
       "      <th>Key Development Sources</th>\n",
       "      <th>Geographic Locations</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2022-07-26</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Wallbridge Mining Company Limited (TSX:WM)</td>\n",
       "      <td>Wallbridge Mining Company Limited Reports Sign...</td>\n",
       "      <td>Wallbridge Mining Company Limited reported pos...</td>\n",
       "      <td>GlobeNewswire – Canada</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2023-05-09</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Good Times Restaurants Inc. (NasdaqCM:GTIM)</td>\n",
       "      <td>Good Times Restaurants Inc. Plans to Open New ...</td>\n",
       "      <td>Good Times Restaurants Inc. announced that it ...</td>\n",
       "      <td>Transcript Collection</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2022-12-02</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Natural Grocers by Vitamin Cottage, Inc. (NYSE...</td>\n",
       "      <td>Natural Grocers Hiring Select Positions for Ne...</td>\n",
       "      <td>Natural Grocers is currently seeking additiona...</td>\n",
       "      <td>PR Newswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2022-12-12</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Southern Empire Resources Corp. (TSXV:SMP)</td>\n",
       "      <td>Southern Empire Resources Corp. Expands Its Mi...</td>\n",
       "      <td>Southern Empire Resources Corp. announces that...</td>\n",
       "      <td>Other</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2022-08-15</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Nate's Food Co. (OTCPK:NHMD)</td>\n",
       "      <td>Nate’s Food Co. Expands Bitcoin Mining Operati...</td>\n",
       "      <td>Nate’s Food Co. announced that it has purchase...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2023-06-15</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Rayonier Advanced Materials Inc. (NYSE:RYAM)</td>\n",
       "      <td>Rayonier Advanced Materials Inc. Announces the...</td>\n",
       "      <td>Rayonier Advanced Materials Inc. hosted a cere...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2022-05-10</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Emerald Holding, Inc. (NYSE:EEX)</td>\n",
       "      <td>Emerald Holding, Inc. Announces New Division D...</td>\n",
       "      <td>Emerald Holding, Inc. announced the creation o...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2023-12-01</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Kermode Resources Ltd. (TSXV:KLM)</td>\n",
       "      <td>Kermode Resources Ltd. Receives Work Permit fo...</td>\n",
       "      <td>Kermode Resources Ltd. announced the receipt o...</td>\n",
       "      <td>SEDAR</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2022-08-10</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Toll Brothers, Inc. (NYSE:TOL)</td>\n",
       "      <td>Toll Brothers Announces Model Homes Now Open a...</td>\n",
       "      <td>Toll Brothers, Inc. announced the opening of 1...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2022-03-28</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Delta Apparel, Inc. (NYSEAM:DLA)</td>\n",
       "      <td>Delta Apparel, Inc. Launches New ‘On-Demand’ D...</td>\n",
       "      <td>Delta Apparel, Inc. announced the expansion of...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2023-05-31</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>PureCycle Technologies, Inc. (NasdaqCM:PCT)</td>\n",
       "      <td>PureCycle Technologies, Inc. Finalizes Financi...</td>\n",
       "      <td>PureCycle Technologies, Inc. announced that it...</td>\n",
       "      <td>Other</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2023-07-17</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Verizon Communications Inc. (NYSE:VZ)</td>\n",
       "      <td>Verizon Continues to Upgrade Daytona's Best Ne...</td>\n",
       "      <td>Verizon has recently made major upgrades to th...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Key Developments By Date Key Developments by Type  \\\n",
       "0                2022-07-26      Business Expansions   \n",
       "3                2023-05-09      Business Expansions   \n",
       "5                2022-12-02      Business Expansions   \n",
       "6                2022-12-12      Business Expansions   \n",
       "7                2022-08-15      Business Expansions   \n",
       "8                2023-06-15      Business Expansions   \n",
       "9                2022-05-10      Business Expansions   \n",
       "11               2023-12-01      Business Expansions   \n",
       "13               2022-08-10      Business Expansions   \n",
       "16               2022-03-28      Business Expansions   \n",
       "18               2023-05-31      Business Expansions   \n",
       "19               2023-07-17      Business Expansions   \n",
       "\n",
       "                                      Company Name(s)  \\\n",
       "0          Wallbridge Mining Company Limited (TSX:WM)   \n",
       "3         Good Times Restaurants Inc. (NasdaqCM:GTIM)   \n",
       "5   Natural Grocers by Vitamin Cottage, Inc. (NYSE...   \n",
       "6          Southern Empire Resources Corp. (TSXV:SMP)   \n",
       "7                        Nate's Food Co. (OTCPK:NHMD)   \n",
       "8        Rayonier Advanced Materials Inc. (NYSE:RYAM)   \n",
       "9                    Emerald Holding, Inc. (NYSE:EEX)   \n",
       "11                  Kermode Resources Ltd. (TSXV:KLM)   \n",
       "13                     Toll Brothers, Inc. (NYSE:TOL)   \n",
       "16                   Delta Apparel, Inc. (NYSEAM:DLA)   \n",
       "18        PureCycle Technologies, Inc. (NasdaqCM:PCT)   \n",
       "19              Verizon Communications Inc. (NYSE:VZ)   \n",
       "\n",
       "                             Key Development Headline  \\\n",
       "0   Wallbridge Mining Company Limited Reports Sign...   \n",
       "3   Good Times Restaurants Inc. Plans to Open New ...   \n",
       "5   Natural Grocers Hiring Select Positions for Ne...   \n",
       "6   Southern Empire Resources Corp. Expands Its Mi...   \n",
       "7   Nate’s Food Co. Expands Bitcoin Mining Operati...   \n",
       "8   Rayonier Advanced Materials Inc. Announces the...   \n",
       "9   Emerald Holding, Inc. Announces New Division D...   \n",
       "11  Kermode Resources Ltd. Receives Work Permit fo...   \n",
       "13  Toll Brothers Announces Model Homes Now Open a...   \n",
       "16  Delta Apparel, Inc. Launches New ‘On-Demand’ D...   \n",
       "18  PureCycle Technologies, Inc. Finalizes Financi...   \n",
       "19  Verizon Continues to Upgrade Daytona's Best Ne...   \n",
       "\n",
       "                            Key Development Situation Key Development Sources  \\\n",
       "0   Wallbridge Mining Company Limited reported pos...  GlobeNewswire – Canada   \n",
       "3   Good Times Restaurants Inc. announced that it ...   Transcript Collection   \n",
       "5   Natural Grocers is currently seeking additiona...             PR Newswire   \n",
       "6   Southern Empire Resources Corp. announces that...                   Other   \n",
       "7   Nate’s Food Co. announced that it has purchase...           GlobeNewswire   \n",
       "8   Rayonier Advanced Materials Inc. hosted a cere...           Business Wire   \n",
       "9   Emerald Holding, Inc. announced the creation o...           Business Wire   \n",
       "11  Kermode Resources Ltd. announced the receipt o...                   SEDAR   \n",
       "13  Toll Brothers, Inc. announced the opening of 1...           GlobeNewswire   \n",
       "16  Delta Apparel, Inc. announced the expansion of...           Business Wire   \n",
       "18  PureCycle Technologies, Inc. announced that it...                   Other   \n",
       "19  Verizon has recently made major upgrades to th...           GlobeNewswire   \n",
       "\n",
       "                  Geographic Locations  \n",
       "0   United States and Canada (Primary)  \n",
       "3   United States and Canada (Primary)  \n",
       "5   United States and Canada (Primary)  \n",
       "6   United States and Canada (Primary)  \n",
       "7   United States and Canada (Primary)  \n",
       "8   United States and Canada (Primary)  \n",
       "9   United States and Canada (Primary)  \n",
       "11  United States and Canada (Primary)  \n",
       "13  United States and Canada (Primary)  \n",
       "16  United States and Canada (Primary)  \n",
       "18  United States and Canada (Primary)  \n",
       "19  United States and Canada (Primary)  "
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "8ed4529e-baff-4dc3-b275-166f3c5add1a",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Key Developments By Date</th>\n",
       "      <th>Key Developments by Type</th>\n",
       "      <th>Company Name(s)</th>\n",
       "      <th>Key Development Headline</th>\n",
       "      <th>Key Development Situation</th>\n",
       "      <th>Key Development Sources</th>\n",
       "      <th>Geographic Locations</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2022-03-28</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Delta Apparel, Inc. (NYSEAM:DLA)</td>\n",
       "      <td>Delta Apparel, Inc. Launches New ‘On-Demand’ D...</td>\n",
       "      <td>Delta Apparel, Inc. announced the expansion of...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2022-05-10</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Emerald Holding, Inc. (NYSE:EEX)</td>\n",
       "      <td>Emerald Holding, Inc. Announces New Division D...</td>\n",
       "      <td>Emerald Holding, Inc. announced the creation o...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2022-07-26</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Wallbridge Mining Company Limited (TSX:WM)</td>\n",
       "      <td>Wallbridge Mining Company Limited Reports Sign...</td>\n",
       "      <td>Wallbridge Mining Company Limited reported pos...</td>\n",
       "      <td>GlobeNewswire – Canada</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2022-08-10</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Toll Brothers, Inc. (NYSE:TOL)</td>\n",
       "      <td>Toll Brothers Announces Model Homes Now Open a...</td>\n",
       "      <td>Toll Brothers, Inc. announced the opening of 1...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2022-08-15</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Nate's Food Co. (OTCPK:NHMD)</td>\n",
       "      <td>Nate’s Food Co. Expands Bitcoin Mining Operati...</td>\n",
       "      <td>Nate’s Food Co. announced that it has purchase...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2022-12-02</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Natural Grocers by Vitamin Cottage, Inc. (NYSE...</td>\n",
       "      <td>Natural Grocers Hiring Select Positions for Ne...</td>\n",
       "      <td>Natural Grocers is currently seeking additiona...</td>\n",
       "      <td>PR Newswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2022-12-12</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Southern Empire Resources Corp. (TSXV:SMP)</td>\n",
       "      <td>Southern Empire Resources Corp. Expands Its Mi...</td>\n",
       "      <td>Southern Empire Resources Corp. announces that...</td>\n",
       "      <td>Other</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2023-05-09</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Good Times Restaurants Inc. (NasdaqCM:GTIM)</td>\n",
       "      <td>Good Times Restaurants Inc. Plans to Open New ...</td>\n",
       "      <td>Good Times Restaurants Inc. announced that it ...</td>\n",
       "      <td>Transcript Collection</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2023-05-31</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>PureCycle Technologies, Inc. (NasdaqCM:PCT)</td>\n",
       "      <td>PureCycle Technologies, Inc. Finalizes Financi...</td>\n",
       "      <td>PureCycle Technologies, Inc. announced that it...</td>\n",
       "      <td>Other</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2023-06-15</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Rayonier Advanced Materials Inc. (NYSE:RYAM)</td>\n",
       "      <td>Rayonier Advanced Materials Inc. Announces the...</td>\n",
       "      <td>Rayonier Advanced Materials Inc. hosted a cere...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2023-07-17</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Verizon Communications Inc. (NYSE:VZ)</td>\n",
       "      <td>Verizon Continues to Upgrade Daytona's Best Ne...</td>\n",
       "      <td>Verizon has recently made major upgrades to th...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2023-12-01</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Kermode Resources Ltd. (TSXV:KLM)</td>\n",
       "      <td>Kermode Resources Ltd. Receives Work Permit fo...</td>\n",
       "      <td>Kermode Resources Ltd. announced the receipt o...</td>\n",
       "      <td>SEDAR</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Key Developments By Date Key Developments by Type  \\\n",
       "16               2022-03-28      Business Expansions   \n",
       "9                2022-05-10      Business Expansions   \n",
       "0                2022-07-26      Business Expansions   \n",
       "13               2022-08-10      Business Expansions   \n",
       "7                2022-08-15      Business Expansions   \n",
       "5                2022-12-02      Business Expansions   \n",
       "6                2022-12-12      Business Expansions   \n",
       "3                2023-05-09      Business Expansions   \n",
       "18               2023-05-31      Business Expansions   \n",
       "8                2023-06-15      Business Expansions   \n",
       "19               2023-07-17      Business Expansions   \n",
       "11               2023-12-01      Business Expansions   \n",
       "\n",
       "                                      Company Name(s)  \\\n",
       "16                   Delta Apparel, Inc. (NYSEAM:DLA)   \n",
       "9                    Emerald Holding, Inc. (NYSE:EEX)   \n",
       "0          Wallbridge Mining Company Limited (TSX:WM)   \n",
       "13                     Toll Brothers, Inc. (NYSE:TOL)   \n",
       "7                        Nate's Food Co. (OTCPK:NHMD)   \n",
       "5   Natural Grocers by Vitamin Cottage, Inc. (NYSE...   \n",
       "6          Southern Empire Resources Corp. (TSXV:SMP)   \n",
       "3         Good Times Restaurants Inc. (NasdaqCM:GTIM)   \n",
       "18        PureCycle Technologies, Inc. (NasdaqCM:PCT)   \n",
       "8        Rayonier Advanced Materials Inc. (NYSE:RYAM)   \n",
       "19              Verizon Communications Inc. (NYSE:VZ)   \n",
       "11                  Kermode Resources Ltd. (TSXV:KLM)   \n",
       "\n",
       "                             Key Development Headline  \\\n",
       "16  Delta Apparel, Inc. Launches New ‘On-Demand’ D...   \n",
       "9   Emerald Holding, Inc. Announces New Division D...   \n",
       "0   Wallbridge Mining Company Limited Reports Sign...   \n",
       "13  Toll Brothers Announces Model Homes Now Open a...   \n",
       "7   Nate’s Food Co. Expands Bitcoin Mining Operati...   \n",
       "5   Natural Grocers Hiring Select Positions for Ne...   \n",
       "6   Southern Empire Resources Corp. Expands Its Mi...   \n",
       "3   Good Times Restaurants Inc. Plans to Open New ...   \n",
       "18  PureCycle Technologies, Inc. Finalizes Financi...   \n",
       "8   Rayonier Advanced Materials Inc. Announces the...   \n",
       "19  Verizon Continues to Upgrade Daytona's Best Ne...   \n",
       "11  Kermode Resources Ltd. Receives Work Permit fo...   \n",
       "\n",
       "                            Key Development Situation Key Development Sources  \\\n",
       "16  Delta Apparel, Inc. announced the expansion of...           Business Wire   \n",
       "9   Emerald Holding, Inc. announced the creation o...           Business Wire   \n",
       "0   Wallbridge Mining Company Limited reported pos...  GlobeNewswire – Canada   \n",
       "13  Toll Brothers, Inc. announced the opening of 1...           GlobeNewswire   \n",
       "7   Nate’s Food Co. announced that it has purchase...           GlobeNewswire   \n",
       "5   Natural Grocers is currently seeking additiona...             PR Newswire   \n",
       "6   Southern Empire Resources Corp. announces that...                   Other   \n",
       "3   Good Times Restaurants Inc. announced that it ...   Transcript Collection   \n",
       "18  PureCycle Technologies, Inc. announced that it...                   Other   \n",
       "8   Rayonier Advanced Materials Inc. hosted a cere...           Business Wire   \n",
       "19  Verizon has recently made major upgrades to th...           GlobeNewswire   \n",
       "11  Kermode Resources Ltd. announced the receipt o...                   SEDAR   \n",
       "\n",
       "                  Geographic Locations  \n",
       "16  United States and Canada (Primary)  \n",
       "9   United States and Canada (Primary)  \n",
       "0   United States and Canada (Primary)  \n",
       "13  United States and Canada (Primary)  \n",
       "7   United States and Canada (Primary)  \n",
       "5   United States and Canada (Primary)  \n",
       "6   United States and Canada (Primary)  \n",
       "3   United States and Canada (Primary)  \n",
       "18  United States and Canada (Primary)  \n",
       "8   United States and Canada (Primary)  \n",
       "19  United States and Canada (Primary)  \n",
       "11  United States and Canada (Primary)  "
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.sort_values(\"Key Developments By Date\")# 按照列col1排序数据，默认升序排列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "46af7604-36b5-4a31-8cb8-d5676d33f0b4",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Key Developments By Date</th>\n",
       "      <th>Key Developments by Type</th>\n",
       "      <th>Company Name(s)</th>\n",
       "      <th>Key Development Headline</th>\n",
       "      <th>Key Development Situation</th>\n",
       "      <th>Key Development Sources</th>\n",
       "      <th>Geographic Locations</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2023-12-01</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Kermode Resources Ltd. (TSXV:KLM)</td>\n",
       "      <td>Kermode Resources Ltd. Receives Work Permit fo...</td>\n",
       "      <td>Kermode Resources Ltd. announced the receipt o...</td>\n",
       "      <td>SEDAR</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2023-07-17</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Verizon Communications Inc. (NYSE:VZ)</td>\n",
       "      <td>Verizon Continues to Upgrade Daytona's Best Ne...</td>\n",
       "      <td>Verizon has recently made major upgrades to th...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2023-06-15</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Rayonier Advanced Materials Inc. (NYSE:RYAM)</td>\n",
       "      <td>Rayonier Advanced Materials Inc. Announces the...</td>\n",
       "      <td>Rayonier Advanced Materials Inc. hosted a cere...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2023-05-31</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>PureCycle Technologies, Inc. (NasdaqCM:PCT)</td>\n",
       "      <td>PureCycle Technologies, Inc. Finalizes Financi...</td>\n",
       "      <td>PureCycle Technologies, Inc. announced that it...</td>\n",
       "      <td>Other</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2023-05-09</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Good Times Restaurants Inc. (NasdaqCM:GTIM)</td>\n",
       "      <td>Good Times Restaurants Inc. Plans to Open New ...</td>\n",
       "      <td>Good Times Restaurants Inc. announced that it ...</td>\n",
       "      <td>Transcript Collection</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2022-12-12</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Southern Empire Resources Corp. (TSXV:SMP)</td>\n",
       "      <td>Southern Empire Resources Corp. Expands Its Mi...</td>\n",
       "      <td>Southern Empire Resources Corp. announces that...</td>\n",
       "      <td>Other</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2022-12-02</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Natural Grocers by Vitamin Cottage, Inc. (NYSE...</td>\n",
       "      <td>Natural Grocers Hiring Select Positions for Ne...</td>\n",
       "      <td>Natural Grocers is currently seeking additiona...</td>\n",
       "      <td>PR Newswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2022-08-15</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Nate's Food Co. (OTCPK:NHMD)</td>\n",
       "      <td>Nate’s Food Co. Expands Bitcoin Mining Operati...</td>\n",
       "      <td>Nate’s Food Co. announced that it has purchase...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2022-08-10</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Toll Brothers, Inc. (NYSE:TOL)</td>\n",
       "      <td>Toll Brothers Announces Model Homes Now Open a...</td>\n",
       "      <td>Toll Brothers, Inc. announced the opening of 1...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2022-07-26</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Wallbridge Mining Company Limited (TSX:WM)</td>\n",
       "      <td>Wallbridge Mining Company Limited Reports Sign...</td>\n",
       "      <td>Wallbridge Mining Company Limited reported pos...</td>\n",
       "      <td>GlobeNewswire – Canada</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2022-05-10</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Emerald Holding, Inc. (NYSE:EEX)</td>\n",
       "      <td>Emerald Holding, Inc. Announces New Division D...</td>\n",
       "      <td>Emerald Holding, Inc. announced the creation o...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2022-03-28</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Delta Apparel, Inc. (NYSEAM:DLA)</td>\n",
       "      <td>Delta Apparel, Inc. Launches New ‘On-Demand’ D...</td>\n",
       "      <td>Delta Apparel, Inc. announced the expansion of...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Key Developments By Date Key Developments by Type  \\\n",
       "11               2023-12-01      Business Expansions   \n",
       "19               2023-07-17      Business Expansions   \n",
       "8                2023-06-15      Business Expansions   \n",
       "18               2023-05-31      Business Expansions   \n",
       "3                2023-05-09      Business Expansions   \n",
       "6                2022-12-12      Business Expansions   \n",
       "5                2022-12-02      Business Expansions   \n",
       "7                2022-08-15      Business Expansions   \n",
       "13               2022-08-10      Business Expansions   \n",
       "0                2022-07-26      Business Expansions   \n",
       "9                2022-05-10      Business Expansions   \n",
       "16               2022-03-28      Business Expansions   \n",
       "\n",
       "                                      Company Name(s)  \\\n",
       "11                  Kermode Resources Ltd. (TSXV:KLM)   \n",
       "19              Verizon Communications Inc. (NYSE:VZ)   \n",
       "8        Rayonier Advanced Materials Inc. (NYSE:RYAM)   \n",
       "18        PureCycle Technologies, Inc. (NasdaqCM:PCT)   \n",
       "3         Good Times Restaurants Inc. (NasdaqCM:GTIM)   \n",
       "6          Southern Empire Resources Corp. (TSXV:SMP)   \n",
       "5   Natural Grocers by Vitamin Cottage, Inc. (NYSE...   \n",
       "7                        Nate's Food Co. (OTCPK:NHMD)   \n",
       "13                     Toll Brothers, Inc. (NYSE:TOL)   \n",
       "0          Wallbridge Mining Company Limited (TSX:WM)   \n",
       "9                    Emerald Holding, Inc. (NYSE:EEX)   \n",
       "16                   Delta Apparel, Inc. (NYSEAM:DLA)   \n",
       "\n",
       "                             Key Development Headline  \\\n",
       "11  Kermode Resources Ltd. Receives Work Permit fo...   \n",
       "19  Verizon Continues to Upgrade Daytona's Best Ne...   \n",
       "8   Rayonier Advanced Materials Inc. Announces the...   \n",
       "18  PureCycle Technologies, Inc. Finalizes Financi...   \n",
       "3   Good Times Restaurants Inc. Plans to Open New ...   \n",
       "6   Southern Empire Resources Corp. Expands Its Mi...   \n",
       "5   Natural Grocers Hiring Select Positions for Ne...   \n",
       "7   Nate’s Food Co. Expands Bitcoin Mining Operati...   \n",
       "13  Toll Brothers Announces Model Homes Now Open a...   \n",
       "0   Wallbridge Mining Company Limited Reports Sign...   \n",
       "9   Emerald Holding, Inc. Announces New Division D...   \n",
       "16  Delta Apparel, Inc. Launches New ‘On-Demand’ D...   \n",
       "\n",
       "                            Key Development Situation Key Development Sources  \\\n",
       "11  Kermode Resources Ltd. announced the receipt o...                   SEDAR   \n",
       "19  Verizon has recently made major upgrades to th...           GlobeNewswire   \n",
       "8   Rayonier Advanced Materials Inc. hosted a cere...           Business Wire   \n",
       "18  PureCycle Technologies, Inc. announced that it...                   Other   \n",
       "3   Good Times Restaurants Inc. announced that it ...   Transcript Collection   \n",
       "6   Southern Empire Resources Corp. announces that...                   Other   \n",
       "5   Natural Grocers is currently seeking additiona...             PR Newswire   \n",
       "7   Nate’s Food Co. announced that it has purchase...           GlobeNewswire   \n",
       "13  Toll Brothers, Inc. announced the opening of 1...           GlobeNewswire   \n",
       "0   Wallbridge Mining Company Limited reported pos...  GlobeNewswire – Canada   \n",
       "9   Emerald Holding, Inc. announced the creation o...           Business Wire   \n",
       "16  Delta Apparel, Inc. announced the expansion of...           Business Wire   \n",
       "\n",
       "                  Geographic Locations  \n",
       "11  United States and Canada (Primary)  \n",
       "19  United States and Canada (Primary)  \n",
       "8   United States and Canada (Primary)  \n",
       "18  United States and Canada (Primary)  \n",
       "3   United States and Canada (Primary)  \n",
       "6   United States and Canada (Primary)  \n",
       "5   United States and Canada (Primary)  \n",
       "7   United States and Canada (Primary)  \n",
       "13  United States and Canada (Primary)  \n",
       "0   United States and Canada (Primary)  \n",
       "9   United States and Canada (Primary)  \n",
       "16  United States and Canada (Primary)  "
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.sort_values(\"Key Developments By Date\", ascending=False)# 按照列col1降序排列数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "79680431-0d8f-4192-a44f-44d8b4ff7581",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "1f2db80d-d2da-461a-9f17-c2f245a64647",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Key Developments By Date</th>\n",
       "      <th>Key Developments by Type</th>\n",
       "      <th>Company Name(s)</th>\n",
       "      <th>Key Development Headline</th>\n",
       "      <th>Key Development Situation</th>\n",
       "      <th>Key Development Sources</th>\n",
       "      <th>Geographic Locations</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2021-03-24</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Clean Seed Capital Group Ltd. (TSXV:CSX)</td>\n",
       "      <td>Clean Seed Capital Group Ltd. to Break Ground ...</td>\n",
       "      <td>Clean Seed Capital Group Ltd. announces the Co...</td>\n",
       "      <td>SEDAR</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2021-04-07</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Curaleaf Holdings, Inc. (TSX:CURA)</td>\n",
       "      <td>Curaleaf Holdings, Inc. Establishes Curaleaf I...</td>\n",
       "      <td>Curaleaf Holdings, Inc. has simultaneously est...</td>\n",
       "      <td>Canada News Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2021-04-12</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>International Business Machines Corporation (N...</td>\n",
       "      <td>IBM Announces Kyndryl, New Independent Company</td>\n",
       "      <td>IBM announced that Kyndryl will be the name of...</td>\n",
       "      <td>Canada News Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2021-05-21</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>KB Home (NYSE:KBH)</td>\n",
       "      <td>KB Home Announces the Grand Opening of Fishers...</td>\n",
       "      <td>KB Home announced the grand opening of Fishers...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2021-07-29</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Rogers Communications Inc. (TSX:RCI.B)</td>\n",
       "      <td>Rogers Communications Continues Canada’s 5G Ne...</td>\n",
       "      <td>Rogers Communications announced that it invest...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2021-10-18</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Lazydays Holdings, Inc. (NasdaqCM:GORV)</td>\n",
       "      <td>Lazydays RV Announces Plans to Open Omaha Deal...</td>\n",
       "      <td>Lazydays, The RV Authority, announced that it ...</td>\n",
       "      <td>PR Newswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2021-11-16</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>The Wendy's Company (NasdaqGS:WEN)</td>\n",
       "      <td>The Wendy's Company's Opens 1,000th Internatio...</td>\n",
       "      <td>The Wendy's Company announced the opening of i...</td>\n",
       "      <td>PR Newswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2021-12-22</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Generation Mining Limited (TSX:GENM)</td>\n",
       "      <td>Generation Mining Limited Agrees to Enter into...</td>\n",
       "      <td>Generation Mining Limited announced that it ha...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2022-03-28</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Delta Apparel, Inc. (NYSEAM:DLA)</td>\n",
       "      <td>Delta Apparel, Inc. Launches New ‘On-Demand’ D...</td>\n",
       "      <td>Delta Apparel, Inc. announced the expansion of...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2022-05-10</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Emerald Holding, Inc. (NYSE:EEX)</td>\n",
       "      <td>Emerald Holding, Inc. Announces New Division D...</td>\n",
       "      <td>Emerald Holding, Inc. announced the creation o...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2022-07-26</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Wallbridge Mining Company Limited (TSX:WM)</td>\n",
       "      <td>Wallbridge Mining Company Limited Reports Sign...</td>\n",
       "      <td>Wallbridge Mining Company Limited reported pos...</td>\n",
       "      <td>GlobeNewswire – Canada</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2022-08-10</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Toll Brothers, Inc. (NYSE:TOL)</td>\n",
       "      <td>Toll Brothers Announces Model Homes Now Open a...</td>\n",
       "      <td>Toll Brothers, Inc. announced the opening of 1...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2022-08-15</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Nate's Food Co. (OTCPK:NHMD)</td>\n",
       "      <td>Nate’s Food Co. Expands Bitcoin Mining Operati...</td>\n",
       "      <td>Nate’s Food Co. announced that it has purchase...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2022-12-02</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Natural Grocers by Vitamin Cottage, Inc. (NYSE...</td>\n",
       "      <td>Natural Grocers Hiring Select Positions for Ne...</td>\n",
       "      <td>Natural Grocers is currently seeking additiona...</td>\n",
       "      <td>PR Newswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2022-12-12</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Southern Empire Resources Corp. (TSXV:SMP)</td>\n",
       "      <td>Southern Empire Resources Corp. Expands Its Mi...</td>\n",
       "      <td>Southern Empire Resources Corp. announces that...</td>\n",
       "      <td>Other</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2023-05-09</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Good Times Restaurants Inc. (NasdaqCM:GTIM)</td>\n",
       "      <td>Good Times Restaurants Inc. Plans to Open New ...</td>\n",
       "      <td>Good Times Restaurants Inc. announced that it ...</td>\n",
       "      <td>Transcript Collection</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2023-05-31</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>PureCycle Technologies, Inc. (NasdaqCM:PCT)</td>\n",
       "      <td>PureCycle Technologies, Inc. Finalizes Financi...</td>\n",
       "      <td>PureCycle Technologies, Inc. announced that it...</td>\n",
       "      <td>Other</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2023-06-15</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Rayonier Advanced Materials Inc. (NYSE:RYAM)</td>\n",
       "      <td>Rayonier Advanced Materials Inc. Announces the...</td>\n",
       "      <td>Rayonier Advanced Materials Inc. hosted a cere...</td>\n",
       "      <td>Business Wire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2023-07-17</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Verizon Communications Inc. (NYSE:VZ)</td>\n",
       "      <td>Verizon Continues to Upgrade Daytona's Best Ne...</td>\n",
       "      <td>Verizon has recently made major upgrades to th...</td>\n",
       "      <td>GlobeNewswire</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2023-12-01</td>\n",
       "      <td>Business Expansions</td>\n",
       "      <td>Kermode Resources Ltd. (TSXV:KLM)</td>\n",
       "      <td>Kermode Resources Ltd. Receives Work Permit fo...</td>\n",
       "      <td>Kermode Resources Ltd. announced the receipt o...</td>\n",
       "      <td>SEDAR</td>\n",
       "      <td>United States and Canada (Primary)</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Key Developments By Date Key Developments by Type  \\\n",
       "10               2021-03-24      Business Expansions   \n",
       "15               2021-04-07      Business Expansions   \n",
       "1                2021-04-12      Business Expansions   \n",
       "17               2021-05-21      Business Expansions   \n",
       "12               2021-07-29      Business Expansions   \n",
       "2                2021-10-18      Business Expansions   \n",
       "14               2021-11-16      Business Expansions   \n",
       "4                2021-12-22      Business Expansions   \n",
       "16               2022-03-28      Business Expansions   \n",
       "9                2022-05-10      Business Expansions   \n",
       "0                2022-07-26      Business Expansions   \n",
       "13               2022-08-10      Business Expansions   \n",
       "7                2022-08-15      Business Expansions   \n",
       "5                2022-12-02      Business Expansions   \n",
       "6                2022-12-12      Business Expansions   \n",
       "3                2023-05-09      Business Expansions   \n",
       "18               2023-05-31      Business Expansions   \n",
       "8                2023-06-15      Business Expansions   \n",
       "19               2023-07-17      Business Expansions   \n",
       "11               2023-12-01      Business Expansions   \n",
       "\n",
       "                                      Company Name(s)  \\\n",
       "10           Clean Seed Capital Group Ltd. (TSXV:CSX)   \n",
       "15                 Curaleaf Holdings, Inc. (TSX:CURA)   \n",
       "1   International Business Machines Corporation (N...   \n",
       "17                                 KB Home (NYSE:KBH)   \n",
       "12             Rogers Communications Inc. (TSX:RCI.B)   \n",
       "2             Lazydays Holdings, Inc. (NasdaqCM:GORV)   \n",
       "14                 The Wendy's Company (NasdaqGS:WEN)   \n",
       "4                Generation Mining Limited (TSX:GENM)   \n",
       "16                   Delta Apparel, Inc. (NYSEAM:DLA)   \n",
       "9                    Emerald Holding, Inc. (NYSE:EEX)   \n",
       "0          Wallbridge Mining Company Limited (TSX:WM)   \n",
       "13                     Toll Brothers, Inc. (NYSE:TOL)   \n",
       "7                        Nate's Food Co. (OTCPK:NHMD)   \n",
       "5   Natural Grocers by Vitamin Cottage, Inc. (NYSE...   \n",
       "6          Southern Empire Resources Corp. (TSXV:SMP)   \n",
       "3         Good Times Restaurants Inc. (NasdaqCM:GTIM)   \n",
       "18        PureCycle Technologies, Inc. (NasdaqCM:PCT)   \n",
       "8        Rayonier Advanced Materials Inc. (NYSE:RYAM)   \n",
       "19              Verizon Communications Inc. (NYSE:VZ)   \n",
       "11                  Kermode Resources Ltd. (TSXV:KLM)   \n",
       "\n",
       "                             Key Development Headline  \\\n",
       "10  Clean Seed Capital Group Ltd. to Break Ground ...   \n",
       "15  Curaleaf Holdings, Inc. Establishes Curaleaf I...   \n",
       "1      IBM Announces Kyndryl, New Independent Company   \n",
       "17  KB Home Announces the Grand Opening of Fishers...   \n",
       "12  Rogers Communications Continues Canada’s 5G Ne...   \n",
       "2   Lazydays RV Announces Plans to Open Omaha Deal...   \n",
       "14  The Wendy's Company's Opens 1,000th Internatio...   \n",
       "4   Generation Mining Limited Agrees to Enter into...   \n",
       "16  Delta Apparel, Inc. Launches New ‘On-Demand’ D...   \n",
       "9   Emerald Holding, Inc. Announces New Division D...   \n",
       "0   Wallbridge Mining Company Limited Reports Sign...   \n",
       "13  Toll Brothers Announces Model Homes Now Open a...   \n",
       "7   Nate’s Food Co. Expands Bitcoin Mining Operati...   \n",
       "5   Natural Grocers Hiring Select Positions for Ne...   \n",
       "6   Southern Empire Resources Corp. Expands Its Mi...   \n",
       "3   Good Times Restaurants Inc. Plans to Open New ...   \n",
       "18  PureCycle Technologies, Inc. Finalizes Financi...   \n",
       "8   Rayonier Advanced Materials Inc. Announces the...   \n",
       "19  Verizon Continues to Upgrade Daytona's Best Ne...   \n",
       "11  Kermode Resources Ltd. Receives Work Permit fo...   \n",
       "\n",
       "                            Key Development Situation Key Development Sources  \\\n",
       "10  Clean Seed Capital Group Ltd. announces the Co...                   SEDAR   \n",
       "15  Curaleaf Holdings, Inc. has simultaneously est...        Canada News Wire   \n",
       "1   IBM announced that Kyndryl will be the name of...        Canada News Wire   \n",
       "17  KB Home announced the grand opening of Fishers...           Business Wire   \n",
       "12  Rogers Communications announced that it invest...           GlobeNewswire   \n",
       "2   Lazydays, The RV Authority, announced that it ...             PR Newswire   \n",
       "14  The Wendy's Company announced the opening of i...             PR Newswire   \n",
       "4   Generation Mining Limited announced that it ha...           GlobeNewswire   \n",
       "16  Delta Apparel, Inc. announced the expansion of...           Business Wire   \n",
       "9   Emerald Holding, Inc. announced the creation o...           Business Wire   \n",
       "0   Wallbridge Mining Company Limited reported pos...  GlobeNewswire – Canada   \n",
       "13  Toll Brothers, Inc. announced the opening of 1...           GlobeNewswire   \n",
       "7   Nate’s Food Co. announced that it has purchase...           GlobeNewswire   \n",
       "5   Natural Grocers is currently seeking additiona...             PR Newswire   \n",
       "6   Southern Empire Resources Corp. announces that...                   Other   \n",
       "3   Good Times Restaurants Inc. announced that it ...   Transcript Collection   \n",
       "18  PureCycle Technologies, Inc. announced that it...                   Other   \n",
       "8   Rayonier Advanced Materials Inc. hosted a cere...           Business Wire   \n",
       "19  Verizon has recently made major upgrades to th...           GlobeNewswire   \n",
       "11  Kermode Resources Ltd. announced the receipt o...                   SEDAR   \n",
       "\n",
       "                  Geographic Locations  \n",
       "10  United States and Canada (Primary)  \n",
       "15  United States and Canada (Primary)  \n",
       "1   United States and Canada (Primary)  \n",
       "17  United States and Canada (Primary)  \n",
       "12  United States and Canada (Primary)  \n",
       "2   United States and Canada (Primary)  \n",
       "14  United States and Canada (Primary)  \n",
       "4   United States and Canada (Primary)  \n",
       "16  United States and Canada (Primary)  \n",
       "9   United States and Canada (Primary)  \n",
       "0   United States and Canada (Primary)  \n",
       "13  United States and Canada (Primary)  \n",
       "7   United States and Canada (Primary)  \n",
       "5   United States and Canada (Primary)  \n",
       "6   United States and Canada (Primary)  \n",
       "3   United States and Canada (Primary)  \n",
       "18  United States and Canada (Primary)  \n",
       "8   United States and Canada (Primary)  \n",
       "19  United States and Canada (Primary)  \n",
       "11  United States and Canada (Primary)  "
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_values([\"Key Developments By Date\",\"Key Development Sources\"], ascending=[True,False])# 先按列col1升序排列，后按col2降序排列数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b70dbda9-91ea-4f66-bffa-5d3e0f3c4b47",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "ef8b92db-58bd-4962-a6c2-fb3b1323de29",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Key Developments By Date</th>\n",
       "      <th>Key Developments by Type</th>\n",
       "      <th>Company Name(s)</th>\n",
       "      <th>Key Development Headline</th>\n",
       "      <th>Key Development Situation</th>\n",
       "      <th>Geographic Locations</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Key Development Sources</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Business Wire</th>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Canada News Wire</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GlobeNewswire</th>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GlobeNewswire – Canada</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Other</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PR Newswire</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SEDAR</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Transcript Collection</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         Key Developments By Date  Key Developments by Type  \\\n",
       "Key Development Sources                                                       \n",
       "Business Wire                                   4                         4   \n",
       "Canada News Wire                                2                         2   \n",
       "GlobeNewswire                                   5                         5   \n",
       "GlobeNewswire – Canada                          1                         1   \n",
       "Other                                           2                         2   \n",
       "PR Newswire                                     3                         3   \n",
       "SEDAR                                           2                         2   \n",
       "Transcript Collection                           1                         1   \n",
       "\n",
       "                         Company Name(s)  Key Development Headline  \\\n",
       "Key Development Sources                                              \n",
       "Business Wire                          4                         4   \n",
       "Canada News Wire                       2                         2   \n",
       "GlobeNewswire                          5                         5   \n",
       "GlobeNewswire – Canada                 1                         1   \n",
       "Other                                  2                         2   \n",
       "PR Newswire                            3                         3   \n",
       "SEDAR                                  2                         2   \n",
       "Transcript Collection                  1                         1   \n",
       "\n",
       "                         Key Development Situation  Geographic Locations  \n",
       "Key Development Sources                                                   \n",
       "Business Wire                                    4                     4  \n",
       "Canada News Wire                                 2                     2  \n",
       "GlobeNewswire                                    5                     5  \n",
       "GlobeNewswire – Canada                           1                     1  \n",
       "Other                                            2                     2  \n",
       "PR Newswire                                      3                     3  \n",
       "SEDAR                                            2                     2  \n",
       "Transcript Collection                            1                     1  "
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 按照Key Development Sources分组 计数\n",
    "df.groupby(\"Key Development Sources\").count()# 返回一个按列col进行分组的Groupby对象"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "id": "65c939ab-76aa-477a-8de0-fe2b3d7c82b5",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Key Development Sources\n",
       "Business Wire            2022-05-11 00:00:00\n",
       "Canada News Wire         2021-04-09 12:00:00\n",
       "GlobeNewswire            2022-06-18 14:24:00\n",
       "GlobeNewswire – Canada   2022-07-26 00:00:00\n",
       "Other                    2023-03-07 00:00:00\n",
       "PR Newswire              2022-03-13 08:00:00\n",
       "SEDAR                    2022-07-28 00:00:00\n",
       "Transcript Collection    2023-05-09 00:00:00\n",
       "Name: Key Developments By Date, dtype: datetime64[ns]"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.groupby(\"Key Development Sources\")[\"Key Developments By Date\"].mean()# 返回按列col1进行分组后，列col2的均值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "60a64017-7207-4232-a721-cabb4720f8af",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "df_group = df.groupby(\"Key Development Sources\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "9a16f64d-2f66-4535-beca-8448c3f3f800",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Key Developments By Date</th>\n",
       "      <th>Key Developments by Type</th>\n",
       "      <th>Company Name(s)</th>\n",
       "      <th>Key Development Headline</th>\n",
       "      <th>Key Development Situation</th>\n",
       "      <th>Geographic Locations</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Key Development Sources</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>Business Wire</th>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Canada News Wire</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GlobeNewswire</th>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GlobeNewswire – Canada</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Other</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>PR Newswire</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SEDAR</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Transcript Collection</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         Key Developments By Date  Key Developments by Type  \\\n",
       "Key Development Sources                                                       \n",
       "Business Wire                                   4                         4   \n",
       "Canada News Wire                                2                         2   \n",
       "GlobeNewswire                                   5                         5   \n",
       "GlobeNewswire – Canada                          1                         1   \n",
       "Other                                           2                         2   \n",
       "PR Newswire                                     3                         3   \n",
       "SEDAR                                           2                         2   \n",
       "Transcript Collection                           1                         1   \n",
       "\n",
       "                         Company Name(s)  Key Development Headline  \\\n",
       "Key Development Sources                                              \n",
       "Business Wire                          4                         4   \n",
       "Canada News Wire                       2                         2   \n",
       "GlobeNewswire                          5                         5   \n",
       "GlobeNewswire – Canada                 1                         1   \n",
       "Other                                  2                         2   \n",
       "PR Newswire                            3                         3   \n",
       "SEDAR                                  2                         2   \n",
       "Transcript Collection                  1                         1   \n",
       "\n",
       "                         Key Development Situation  Geographic Locations  \n",
       "Key Development Sources                                                   \n",
       "Business Wire                                    4                     4  \n",
       "Canada News Wire                                 2                     2  \n",
       "GlobeNewswire                                    5                     5  \n",
       "GlobeNewswire – Canada                           1                     1  \n",
       "Other                                            2                     2  \n",
       "PR Newswire                                      3                     3  \n",
       "SEDAR                                            2                     2  \n",
       "Transcript Collection                            1                     1  "
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_group.count()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "edad5184-0b4d-4276-8fae-5e882138e5a1",
   "metadata": {
    "tags": []
   },
   "source": [
    "### 多个条件分组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "id": "d478e104-c68b-42d1-8509-a11fca45a057",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "df_group = pd.DataFrame({'A': [1, 1, 2, 2, 3, 3],\n",
    "                   'B': [2, 3, 1, 2, 1, 3],\n",
    "                   'C': [3, 4, 5, 6, 7, 8]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "id": "8ea9df7f-381f-4b3c-9f91-332fe039df6b",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead tr th {\n",
       "        text-align: left;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <th colspan=\"2\" halign=\"left\">1</th>\n",
       "      <th colspan=\"2\" halign=\"left\">2</th>\n",
       "      <th colspan=\"2\" halign=\"left\">3</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>1</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>2.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>3.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>8.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "A    1         2         3     \n",
       "B    2    3    1    2    1    3\n",
       "A  1.0  1.0  2.0  2.0  3.0  3.0\n",
       "B  2.0  3.0  1.0  2.0  1.0  3.0\n",
       "C  3.0  4.0  5.0  6.0  7.0  8.0"
      ]
     },
     "execution_count": 145,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_group.groupby([\"A\",\"B\"])[[\"A\",\"B\",\"C\"]].mean().T# 返回一个按多列进行分组的Groupby对象"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21979d2c-8a5f-45ca-8cdd-b808e1c36da1",
   "metadata": {},
   "source": [
    "### 判断条件去分组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "9ba3603f-5e59-4a2d-b799-7c41e455a7ad",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "df_group = pd.DataFrame({'A': [1, 1, 2, 2, 3, 3],\n",
    "                   'B': [2, 3, 1, 2, 1, 3],\n",
    "                   'C': [3, 4, 5, 6, 7, 8]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "f87c4c38-fd95-46c2-a5ec-76a357056b03",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "grouped = df_group.groupby(df_group['C'] > 5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "fa6e03d0-9c3d-4f72-b821-7410926a8302",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "mean_values = grouped.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "d44becde-c50d-4d1c-9c97-be8563e023c8",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              A    B    C\n",
      "C                        \n",
      "False  1.333333  2.0  4.0\n",
      "True   2.666667  2.0  7.0\n"
     ]
    }
   ],
   "source": [
    "print(mean_values)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "addd03f3-3865-4dc0-a603-943af291a2d5",
   "metadata": {
    "tags": []
   },
   "source": [
    "### 透视表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "id": "e4398061-d8c5-475c-8fff-d235508a8139",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "df_group = pd.DataFrame({'A': [1, 1, 2, 2, 3, 3],\n",
    "                   'B': [2, 3, 1, 2, 1, 3],\n",
    "                   'C': [3, 4, 5, 6, 7, 8]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "id": "c4b7a7a1-dcea-4c9b-9608-e9ad1b5a961a",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\666\\AppData\\Local\\Temp\\ipykernel_42228\\4292440653.py:1: FutureWarning: The provided callable <built-in function max> is currently using DataFrameGroupBy.max. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string \"max\" instead.\n",
      "  df_group.pivot_table(index=\"C\", values=[\"A\",\"B\",\"C\"], aggfunc=max)# 创建一个按列col1进行分组，并计算col2和col3的最大值的数据透视表\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B\n",
       "C      \n",
       "3  1  2\n",
       "4  1  3\n",
       "5  2  1\n",
       "6  2  2\n",
       "7  3  1\n",
       "8  3  3"
      ]
     },
     "execution_count": 159,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 实际体验不如grouby\n",
    "df_group.pivot_table(index=\"C\", values=[\"A\",\"B\",\"C\"], aggfunc=max)# 创建一个按列col1进行分组，并计算col2和col3的最大值的数据透视表"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e248a7cf-4c44-44cb-85fe-8cbbaebc40fb",
   "metadata": {},
   "source": [
    "### 分组组合函数操作   agg  apply    \n",
    "后面案例有使用方法"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1c3c27f4-e4c5-46db-81de-0c7643d31094",
   "metadata": {},
   "source": [
    "- agg"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "id": "78f3c939-9f21-48bd-8a8c-1178cbdaef7c",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "df_group = pd.DataFrame({'A': [1, 1, 2, 2, 3, 3],\n",
    "                   'B': [2, 3, 1, 2, 1, 3],\n",
    "                   'C': [3, 4, 5, 6, 7, 8]})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 184,
   "id": "d5876c66-a150-4cca-b0e2-1e9f7908ea74",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\666\\AppData\\Local\\Temp\\ipykernel_42228\\896637997.py:1: FutureWarning: The provided callable <function sum at 0x00000158BD6C8540> is currently using DataFrameGroupBy.sum. In a future version of pandas, the provided callable will be used directly. To keep current behavior pass the string \"sum\" instead.\n",
      "  df_group.groupby(\"C\").agg(np.sum)# 返回按列col1分组的所有列的均值\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B\n",
       "C      \n",
       "3  1  2\n",
       "4  1  3\n",
       "5  2  1\n",
       "6  2  2\n",
       "7  3  1\n",
       "8  3  3"
      ]
     },
     "execution_count": 184,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_group.groupby(\"C\").agg(np.sum)# 返回按列col1分组的所有列的均值     "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "id": "d7b5d819-8c70-4df0-a64c-c770e6751010",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B\n",
       "C      \n",
       "3  1  2\n",
       "4  1  3\n",
       "5  2  1\n",
       "6  2  2\n",
       "7  3  1\n",
       "8  3  3"
      ]
     },
     "execution_count": 176,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_group.groupby(\"C\").agg(np.abs)# 返回按列col1分组的所有列的均值   "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f7ef1cbb-63be-4b42-b4ff-03f782fee06a",
   "metadata": {},
   "source": [
    "- applay"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 198,
   "id": "39244c0a-b281-4bc0-8902-525355e0bbb2",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A    2.0\n",
       "B    2.0\n",
       "C    5.5\n",
       "dtype: float64"
      ]
     },
     "execution_count": 198,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_group.apply(np.mean)# 对DataFrame中的每一列应用函数np.mean   apply  可以接很多自定义函数 操作性更强 可以对列或者行进行整体处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "id": "3dcb7107-eab0-42f7-ae97-ad6151e275c2",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    3\n",
       "1    4\n",
       "2    5\n",
       "3    6\n",
       "4    7\n",
       "5    8\n",
       "dtype: int64"
      ]
     },
     "execution_count": 194,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_group.apply(np.max,axis=1)# 对DataFrame中的每一行应用函数np.max"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "90f1fcfd-fda1-4c4b-a96c-a27283b4e618",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
